#####################
# Descriptive data
#####################

rm (list = ls())

setwd("~/Dropbox/Climate change and disasters/07_replication")

sink("01_descriptive_climate_covariates.txt")

library(foreign)
library(stargazer)
library(Hmisc)
library(ggplot2)
library(tidyverse)
library(readstata13)
library(did)

###############################
# Load and prepare clean data
###############################

# load
load("disasters_attitudes.RData")
dim(d)

# check treatments
table(d$first_treat_fire, exclude = NULL)
table(d$first_treat_flood, exclude = NULL)
table(d$first_treat_severestorm, exclude = NULL)
table(d$first_treat_hurricane, exclude = NULL)

# check treatments not used because lack of exposure
table(d$first_treat_tornado, exclude = NULL)
table(d$first_treat_snow, exclude = NULL)
table(d$first_treat_ice, exclude = NULL)
table(d$first_treat_mud, exclude = NULL)
table(d$first_treat_coastals, exclude = NULL)

# check covariates
describe(d$id)
table(d$educ_10, exclude = NULL)
table(d$gender_10, exclude = NULL)
table(d$birthyr_10, exclude = NULL)
table(d$pi_10, exclude = NULL)

# check survey
table(d$survey, exclude = NULL)

# check outcome
table(d$outcome_descending, exclude = NULL)

# data
descriptive = data.frame(d$outcome_descending,d$first_treat_fire,d$first_treat_flood,d$first_treat_hurricane,d$first_treat_severestorm,d$educ_10,d$gender_10,d$birthyr_10)
stargazer(descriptive, type = "text")

sink()

